class Solution {
    public static int strToInt(String str) {
        int num = 0, limit = Integer.MAX_VALUE / 10;
        int i = 0, sign = 1;
        int length = str.length();
        if (length == 0) return 0;
        while (str.charAt(i) == ' ') {
            if (++i == length) return 0;
        }
        if (str.charAt(i) == '-') {
            sign = -1;
            i++;
        } else if (str.charAt(i) == '+') {
            i++;
        }
        for (; i < length; i++) {
            if (str.charAt(i) < '0' || str.charAt(i) > '9') break;
            if (num > limit || (num == limit && str.charAt(i) > '7')) {
                return sign == 1 ? Integer.MAX_VALUE : Integer.MIN_VALUE;
            }
            num = num * 10 + str.charAt(i) - '0';
        }
        return sign * num;
    }

    public static void main(String[] args) {
        double a = 0;
        System.out.println(a);
        strToInt("-91283472332");
    }
}